import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:lib_database/lib_database.dart';
import 'package:lib_util/utils/utils.dart';

class ChainLogo extends StatelessWidget {
  final Chain chain;
  final double size;

  const ChainLogo({super.key, required this.chain, required this.size});

  @override
  Widget build(BuildContext context) {
    return chain.shortName.startsWith(Config.customChainShortNamePrefix) && Utils.isEmpty(chain.logo)
        ? Container(
            width: size,
            height: size,
            decoration: const BoxDecoration(color: Colors.black, shape: BoxShape.circle),
            child: Center(
              child: Text(
                chain.shortName
                    .substring(Config.customChainShortNamePrefix.length, Config.customChainShortNamePrefix.length + 1),
                style: TextStyle(color: Colors.white, fontSize: size.sp / 2, fontWeight: FontWeight.bold),
              ),
            ),
          )
        : Image.asset(
            chain.logo,
            width: size,
            height: size,
          );
  }
}
